<!DOCTYPE html>
<html>
<head>
    <title>Demo</title>
    <script src="/webjars/jquery/1.8.2/jquery.min.js"></script>
</head>
<body>

<h4>Post new employee</h4>

<div>
    <label>Username</label><input id="username" type="text" name="username"><br>
    <label>Name</label><input id="firstname" type="text" name="firstname"><br>
    <label>Surname</label><input id="surname" type="text" name="surname">
    <button onclick="post()">Create</button>
</div>
<br/>
<label id="result"></label>


<script>

    function post() {
        var username = $("#username").val();
        var firstname = $("#firstname").val();
        var surname = $("#surname").val();
        $.post(
                'employees',
                JSON.stringify({ username: username, firstname: firstname, surname: surname }),
                function(response){
                    $("#result").html(response);
                }
                //'json'
        )
        return false;
    }


</script>

</body>

</html>